<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
    <style>
        table img{width: 40px}
    </style>
    <body>

    <div><b>问题分类:</b></div>
    <div style="width:100%;">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" iconCls="icon-add" onclick="addRow()" plain="true">增加</a>
                        <a class="mini-button" iconCls="icon-remove" onclick="removeRow()" plain="true">删除</a>
                        <span class="separator"></span>
                        <a class="mini-button" iconCls="icon-save" onclick="saveData()" plain="true">保存</a>
                    </td>

                </tr>
            </table>
        </div>
    </div>
    <div id="datagrid1" showPager="false" class="mini-datagrid"  style="width:100%;height:250px;border: 1px solid gray"
         url="Wkorder/listAllQuestionCategory" idField="id"
         allowResize="true"
         allowCellEdit="true" allowCellSelect="true" multiSelect="true">

        <div property="columns">
            <div type="checkcolumn"></div>
            <div field="id"  width="100px">ID
                <input class="mini-textbox" style="width:100%;"/>
            </div>
            <div field="name"  width="100px">名称
                <input class="mini-textbox" property="editor" style="width:100%;"/>
            </div>
            <div field="parent_category_id"  width="100px">上级ID
                <input class="mini-textbox" property="editor" style="width:100%;"/>
            </div>
            <div field="remark"  width="100px">备注
                <input class="mini-textbox" property="editor" style="width:100%;"/>
            </div>
        </div>
    </div>

    <hr>

    <div><b>问题相应人Mapping表:</b></div>
    <div style="width:100%;">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" iconCls="icon-add" onclick="addRowB()" plain="true">增加</a>
                        <a class="mini-button" iconCls="icon-remove" onclick="removeRowB()" plain="true">删除</a>
                        <span class="separator"></span>
                        <a class="mini-button" iconCls="icon-save" onclick="saveDataB()" plain="true">保存</a>
                    </td>

                </tr>
            </table>
        </div>
    </div>
    <div id="datagrid2" showPager="false" class="mini-datagrid"  style="width:100%;height:250px;border: 1px solid gray"
         url="Wkorder/listAllQuestionCategoryMappingUser" idField="id"
         allowResize="true"
         allowCellEdit="true" allowCellSelect="true" multiSelect="true" >
        <div property="columns">
            <div type="checkcolumn"></div>
            <div field="id"  width="100px">ID
                <input class="mini-textbox" style="width:100%;"/>
            </div>
            <div field="category_id"  width="100px">问题类型ID
                <input class="mini-textbox" property="editor" style="width:100%;"/>
            </div>
            <div field="user_id"  width="300px">相关人员
                <input class="mini-textbox" property="editor" style="width:100%;"/>
            </div>
            <div field="procedure_level"  width="300px">权重（权重大则优先收到通知.）
                <input class="mini-textbox" property="editor" style="width:100%;"/>
            </div>
        </div>
    </div>

    <hr>

    <script type="text/javascript">
        mini.parse();

        var grid = mini.get("datagrid1");
        grid.load();

        ///////////////////////////////////////////////////////

        function addRow() {
            var newRow = { emp_no: "员工英文名" };
            grid.addRow(newRow, 0);
        }
        function removeRow() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                grid.removeRows(rows, true);
            }
        }
        function saveData() {

            var data = grid.getChanges();
            var json = mini.encode(data);

            grid.loading("保存中，请稍后......");
            $.ajax({
                url: "/Wkorder/updateQuestionCategory",
                data: { data: json },
                type: "post",
                success: function (text) {
                    grid.reload();
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

    </script>

    <script type="text/javascript">
        mini.parse();

        var grid2 = mini.get("datagrid2");
        grid2.load();

        ///////////////////////////////////////////////////////

        function addRowB() {
            var newRow = { emp_no: "员工英文名" };
            grid2.addRow(newRow, 0);
        }
        function removeRowB() {
            var rows = grid2.getSelecteds();
            if (rows.length > 0) {
                grid2.removeRows(rows, true);
            }
        }
        function saveDataB() {

            var data = grid2.getChanges();
            var json = mini.encode(data);

            grid2.loading("保存中，请稍后......");
            $.ajax({
                url: "/Wkorder/updateQuestionCategoryMappingUser",
                data: { data: json },
                type: "post",
                success: function (text) {
                    grid2.reload();
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

    </script>

    </body>
</block>